#include "promlist.h"
#include "hypersphere.h"

void Promlist::Initialise(int numDimension, int promlistSize, double *solution, double radius, double funcval)
{
  m_list[position].setRegion(numDimension, solution, radius, funcval);
  position++;
  m_numInList++;
  whichToOverWrite++;
}

// clears the tabu list after local minimisation
void Promlist::Reset(int promlistSize)
{
  m_list.clear();
  position=0;
  m_numInList=0;
  whichToOverWrite=0;
  m_list.resize(promlistSize);
}

double Promlist::Threshold(int promlistSize)
{
  double threshold = 0.0;

  for(int i = 0; i < promlistSize; i++)
  {
    threshold += m_list[i].m_funcval;
  }
  threshold /= promlistSize;

  return threshold;
}

// tests the tabu list methods
double Promlist::Threshold(int promlistSize, double origValue)
{
  double threshold = 0.0;

  for(int i = 0; i < promlistSize; i++)
  {
    threshold += fabs(m_list[i].m_funcval-origValue);
  }
  threshold /= promlistSize;

  return threshold;
}

/*
ostream &operator<<(ostream &os, Hypersphere &X)
{
os << X.m_radius << endl;

return ( os );
}
*/